package org.arithmetic.array;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by LUOLIANG on 2016/9/11.
 */
public class getMaxAndMin {
    public static void execute(int[] arr, int len) {
        if (len <= 100000) {
            Arrays.sort(arr);
            int m = 0;
            int n = 0;
            if (len == 1) {
                System.out.print(0);
                System.out.print(0);
                return;
            } else {
                int min = arr[1] - arr[0];
                int max = arr[len - 1] - arr[0];
                if (max == min) {
                    System.out.print(min + " ");
                    System.out.print(max);
                    return;
                }
                for (int i = 0; i < len; i++) {

                    for (int j = len - i - 1; j >= 0; j--) {
                        if (arr[j] - arr[i] == min) {
                            m++;
                        }
                        if (arr[j] - arr[i] == max) {
                            n++;
                        }
                    }
                }
                System.out.print(m + " ");
                System.out.print(n);
            }
        }


    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入N：");
        int n = input.nextInt();
        System.out.println("请输入数组：");
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = input.nextInt();
        }

        execute(arr, arr.length);
    }

}

